// utils/confirmOrder/confirmOrder.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        // hours: '0' + 0,   // 时
        // minute: '0' + 0,   // 分
        // second: '0' + 0,    // 秒
        orderNo: 0,
        serviceDesc: '',
        orderId: null
    },
    /**
     *back事件函数
     */
    back: function () {
        wx.navigateBack({
            delta: 2
        })
    },

    /**
     * 查看订单详情
     */
    detial: function () {

        wx.navigateTo({
            url: '../grabSuccess/grabSuccess?orderId=' + this.data.orderId,
        })
        console.log(this.data.orderId)
    },

    setInterval: function () {
        const that = this
        var second = that.data.second
        var minute = that.data.minute
        var hours = that.data.hours
         setInterval(function () {  // 设置定时器
            second++
            if (second >= 60) {
                second = 0  //  大于等于60秒归零
                minute++
                if (minute >= 60) {
                    minute = 0  //  大于等于60分归零
                    hours++
                    if (hours < 10) {
                        // 少于10补零
                        that.setData({
                            hours: '0' + hours
                        })
                    } else {
                        that.setData({
                            hours: hours
                        })
                    }
                }
                if (minute < 10) {
                    // 少于10补零
                    that.setData({
                        minute: '0' + minute
                    })
                } else {
                    that.setData({
                        minute: minute
                    })
                }
            }
            if (second < 10) {
                // 少于10补零
                that.setData({
                    second: '0' + second
                })
            } else {
                that.setData({
                    second: second
                })
            }
        }, 1000)
    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        // this.setInterval()
        let orderId = options.orderId;
        let that = this;
        // console.log(orderId);
        wx.request({
            url: 'https://www.xiaozheng8.com/serviceOrder/receiveFindById',
            method: 'post',
            data: {
                orderId: orderId,
                userId:wx.getStorageSync("userId"),
            },
            success: function (res) {
                console.log(res)
                that.setData({
                    orderNo: res.data.data.orderNo,
                    serviceDesc: res.data.data.serviceDesc,
                    orderId: res.data.data.orderId
                })
                console.log(res.data.data.orderNo + '这是传过来的orderNo'),
                console.log(that.data.orderNo + '这是我的 ')
            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})